<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<style>
	label {width: auto;}
	.opr {margin: 3px 2px;}
	.dispose {text-decoration: line-through; color: red;}
	ul.infoshow {padding:5px 0 0 5px; overflow:auto; width: 80%;}
	ul.infoshow li {line-height: 30px; float:left; margin-right: 15px;}
	.opdisabled {text-decoration: line-through; color: #DDD; line-height: 21px;}
	td.ongoing {background-color: #99FF99; color: #333;}
	td.finished {background-color: #ddd;}
	.ps_2 {background-color: #DDD}
	.ps_3 {background-color: #99FF99}
</style>

<script>
	$(function(){
		polish_year_droplist("year_byper", 
			${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectYear ne null ? formEntity.condVO.condProjectYear : 'null'});
			
			
		polish_month_droplist("month_byper",
			${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectMonth ne null && formEntity.condVO.condProjectMonth ne '' ? formEntity.condVO.condProjectMonth : 'null'}, false);
		
		$("#month_byper").change(function(){
			if ($("#year_byper").val() == "") {
				alertMsg.error("请先选择年份....");
				$("#combox_month_byper").find("a[name='condVO.condProjectMonth']").text("所有");
			}
		});
		
		$("#year_byper").change(function(){
			if ($("#year_byper").val() == "") {
				$("#month_byper").val("");
				$("#combox_month_byper").find("a[name='condVO.condProjectMonth']").text("所有");
			}
		});
		
	});
</script>

<form id="pagerForm" method="post" action="app/statistic.do?action=pageByPersonIndex">
	<input type="hidden" name="pageNum" value="${pagingBean ne null ? pagingBean.currentPage : 1}" />
	<input type="hidden" name="numPerPage" value="${pagingBean ne null ? pagingBean.pageSize : 20}" />
</form>

<!-- SearchBar -->
<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="app/statistic.do?action=pageByPersonIndex" method="post" id="searchForm" rel="pagerForm">
		<div class="searchBar">
			<table class="searchContent" id="record_form">
				<tr>
					<td>
						<label>所属年份：</label>
						<select class="combox" id="year_byper" name="condVO.condProjectYear" style="width: 120px"></select>
					</td>
					<td>
						<label>所属月份：</label>
						<select class="combox" id="month_byper" name="condVO.condProjectMonth" style="width: 120px">
							<option value="">所有</option>
						</select>
					</td>
					<td>
						<label>分配状态：</label>
						<select class="combox" id="projectAssignment" name="condVO.condProjectAssignmentStatus" style="width: 120px">
							<option value="" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAssignmentStatus eq '' ? 'selected' : ''}>所有</option>
							<option value="1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAssignmentStatus eq '1' ? 'selected' : ''}>已分配</option>
							<option value="0" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAssignmentStatus eq '0' ? 'selected' : ''}>待分配</option>
						</select>
					</td>
					<td>
						<label>项目负责人：</label>
						<input id="projectMgrId" name="mgr.id" value="${formEntity ne null && formEntity.projectManager ne null ? entity.projectManager.id : ''}" type="hidden"/>
						<input id="projectMgr" type="text" name="mgr.username" rel="pagerForm" value="${formEntity ne null && formEntity.projectManager ne null ? formEntity.projectManager.username : ''}" postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="mgr" style="width: 120px;float:left"/>
					</td>
					<td>
						<label>项目名称：</label>
						<input type="text" name="projectName" rel="pagerForm" value="${formEntity ne null ? formEntity.projectName : ''}" style="width: 140px;float:left"/>
					</td>
				</tr>
				<tr>
					<td>
						<label>项目进展：</label>
						<select class="combox" name="condVO.condProjectProcess" style="width: 120px">
							<option value="">所有</option>
							<option value="-1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq '-1' ? 'selected' : ''}>项目分配</option>
							<logic:present name="processes">
								<logic:iterate name="processes" id="process">
									<option value="${process.nodeTitle}" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq process.nodeTitle ? 'selected' : ''}>${process.nodeTitle}</option>
								</logic:iterate>
							</logic:present>
							<option value="-10" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq '-10' ? 'selected' : ''}>审批结束</option>
						</select>
					</td>
					<td id="proj_status">
						<label>项目状态：</label>
						<select class="combox" name="condVO.condProjectStatus" style="width: 120px">
							<option value="" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '' ? 'selected' : ''}>所有</option>
							<option value="-9" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-9' ? 'selected' : ''}>待分配</option>
							<option value="0" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '0' ? 'selected' : ''}>材料待提交</option>
							<option value="1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '1' ? 'selected' : ''}>审批中</option>
							<option value="-1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-1' ? 'selected' : ''}>审批退回</option>
							<option value="-2" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-2' ? 'selected' : ''}>已暂停</option>
							<option value="-10" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-10' ? 'selected' : ''}>审批结束</option>
						</select>
					</td>
					<td id="proj_status">
						<label>审批结果：</label>
						<select class="combox" name="condVO.condProjectAuditResult" style="width: 120px">
							<option value="" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '' ? 'selected' : ''}>所有</option>
							<option value="-9" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '-9' ? 'selected' : ''}>审批中</option>
							<option value="2" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '2' ? 'selected' : ''}>审批否决</option>
							<option value="3" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '3' ? 'selected' : ''}>审批通过</option>
						</select>
					</td>
					<td>
						<label>项目登记人：</label>
						<input id="projectRecorderId" name="recorder.id" value="${formEntity ne null && formEntity.projectRecorder ne null ? entity.projectRecorder.id : ''}" type="hidden"/>
						<input id="projectRecorder" type="text" name="recorder.username" rel="pagerForm" value="${formEntity ne null && formEntity.projectRecorder ne null ? formEntity.projectRecorder.username : ''}" postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="recorder" style="width: 120px;float:left"/>
					</td>
				</tr>
			</table>
			<div class="subBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				</ul>
			</div>
		</div>
		<input type="hidden" name="currentindex" id="currentindex" value="${currentindex ne null ? currentindex : 0}" />
	</form>
</div>

<!-- Body -->
<div class="pageContent">
	<table class="table" width="100%" layoutH="${module eq null || module eq 'archive' ? 143 : 110}">
		<thead>
			<tr>
				<th align="center">序号</th>
				<th align="center" class="thover">项目人员</th>
				<th align="center">项目负责/参与个数</th>
				<th align="center">项目编号</th>
				<th align="center">项目名称</th>
				<th align="center">项目推荐时间</th>
				<th align="center">项目登记人</th>
				<th align="center">项目登记时间</th>
				<th align="center">行业类别</th>
				<th align="center">项目进展</th>
				<th align="center">项目状态</th>
				<th align="center">审批结果</th>
			</tr>
		</thead>
		<tbody>
			<logic:present name="datagrid">
				<logic:iterate name="datagrid" id="entity" indexId="idx">
					<bean:define id='e' name="entity" property="value" />
					<c:set var="ownerEntity" value="${e[0]}"></c:set>
					<c:set var="partiEntity" value="${e[1]}"></c:set>
					<tr>
						<td rowspan="${fn:length(e[0]) + fn:length(e[1])}">${idx+1}</td>
						<td rowspan="${fn:length(e[0]) + fn:length(e[1])}" class="thover" style="text-align:center">${entity.key}</td>
						<c:choose>
							<c:when test="${fn:length(e[0]) gt 0}">
								<td rowspan="${fn:length(e[0])}"><b>${fn:length(e[0])}</b> (负责)</td>
								<c:forEach items="${ownerEntity}" var="project" begin="0" end="0">
									<td style="text-align:center">${project.projectNo}</td>
									<td style="text-align:left">${project.projectName}</td>
									<td><fmt:formatDate value="${project.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
									<td>${project.projectRecorder ne null ? project.projectRecorder.username : '---'}</td>
									<td><fmt:formatDate value="${project.projectCreationTime}" type="date" pattern="yyyy-MM-dd"/></td>
									<td style="text-align:left">${project.projectType.dictKey}</td>
									<td>
										<c:choose>
											<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">项目分配</c:when>
											<c:when test="${project.currentProcess ne null}">${project.currentProcess.nodeTitle}</c:when>
											<c:when test="${project.projectStatus eq 2 || project.projectStatus eq 3 || project.projectStatus eq -2}">审批结束</c:when>
											<c:otherwise>---</c:otherwise>
										</c:choose>
									</td>
									<td ${project.projectStatus eq -2 ? 'style="background-color: #FF9500"' : (project.projectStatus eq -1 ? 'style="background-color: #FFD20F"' : '')}>
										<c:choose>
											<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">待分配</c:when>
											<c:when test="${project.projectStatus eq 0}">材料待提交</c:when>
											<c:when test="${project.projectStatus eq 1}">审批中</c:when>
											<c:when test="${project.projectStatus eq -1}">审批退回</c:when>
											<c:when test="${project.projectStatus eq -2}">已暂停</c:when>
											<c:when test="${project.projectStatus eq 2 || project.projectStatus eq 3}">审批结束</c:when>
											<c:otherwise>---</c:otherwise>
										</c:choose>
									</td>
									<td class="ps_${project.projectStatus}">
										<c:choose>
											<c:when test="${project.projectStatus eq 2}">否决</c:when>
											<c:when test="${project.projectStatus eq 3}">通过</c:when>
											<c:when test="${project.projectStatus ne -2}">审批中</c:when>
											<c:otherwise>---</c:otherwise>
										</c:choose>
									</td>
								</c:forEach>
							</c:when>
							<c:otherwise>
								<td rowspan="${fn:length(e[1])}"><b>${fn:length(e[1])}</b> (参与)</td>
									<c:forEach items="${partiEntity}" var="project" begin="0" end="0">
										<td style="text-align:center">${project.projectNo}</td>
										<td style="text-align:left">${project.projectName}</td>
										<td><fmt:formatDate value="${project.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
										<td>${project.projectRecorder ne null ? project.projectRecorder.username : '---'}</td>
										<td><fmt:formatDate value="${project.projectCreationTime}" type="date" pattern="yyyy-MM-dd"/></td>
										<td style="text-align:left">${project.projectType.dictKey}</td>
										<td>
											<c:choose>
												<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">项目分配</c:when>
												<c:when test="${project.currentProcess ne null}">${project.currentProcess.nodeTitle}</c:when>
												<c:otherwise>---</c:otherwise>
											</c:choose>
										</td>
										<td ${project.projectStatus eq -2 ? 'style="background-color: #FF9500"' :  (project.projectStatus eq -1 ? 'style="background-color: #FFD20F"' : '')}>
											<c:choose>
												<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">待分配</c:when>
												<c:when test="${project.projectStatus eq 0}">材料待提交</c:when>
												<c:when test="${project.projectStatus eq 1}">审批中</c:when>
												<c:when test="${project.projectStatus eq -1}">审批退回</c:when>
												<c:when test="${project.projectStatus eq -2}">已暂停</c:when>
												<c:when test="${project.projectStatus eq 2 || project.projectStatus eq 3}">审批结束</c:when>
												<c:otherwise>---</c:otherwise>
											</c:choose>
										</td>
										<td class="ps_${project.projectStatus}">
											<c:choose>
												<c:when test="${project.projectStatus eq 2}">否决</c:when>
												<c:when test="${project.projectStatus eq 3}">通过</c:when>
												<c:when test="${project.projectStatus ne -2}">审批中</c:when>
												<c:otherwise>---</c:otherwise>
											</c:choose>
										</td>
									</c:forEach>
							</c:otherwise>
						</c:choose>
					</tr>
					
					<c:if test="${fn:length(e[0]) gt 1}">
						<c:forEach items="${ownerEntity}" var="project" begin="1">
							<tr ${subIdx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
								<td style="text-align:center">${project.projectNo}</td>
								<td style="text-align:left">${project.projectName}</td>
								<td><fmt:formatDate value="${project.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
								<td>${project.projectRecorder ne null ? project.projectRecorder.username : '---'}</td>
								<td><fmt:formatDate value="${project.projectCreationTime}" type="date" pattern="yyyy-MM-dd"/></td>
								<td style="text-align:left">${project.projectType.dictKey}</td>
								<td>
									<c:choose>
										<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">项目分配</c:when>
										<c:when test="${project.currentProcess ne null}">${project.currentProcess.nodeTitle}</c:when>
										<c:otherwise>---</c:otherwise>
									</c:choose>
								</td>
								<td ${project.projectStatus eq -2 ? 'style="background-color: #FF9500"' :  (project.projectStatus eq -1 ? 'style="background-color: #FFD20F"' : '')}>
									<c:choose>
										<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">待分配</c:when>
										<c:when test="${project.projectStatus eq 0}">材料待提交</c:when>
										<c:when test="${project.projectStatus eq 1}">审批中</c:when>
										<c:when test="${project.projectStatus eq -1}">审批退回</c:when>
										<c:when test="${project.projectStatus eq -2}">已暂停</c:when>
										<c:when test="${project.projectStatus eq 2 || project.projectStatus eq 3}">审批结束</c:when>
										<c:otherwise>---</c:otherwise>
									</c:choose>
								</td>
								<td class="ps_${project.projectStatus}">
									<c:choose>
										<c:when test="${project.projectStatus eq 2}">否决</c:when>
										<c:when test="${project.projectStatus eq 3}">通过</c:when>
										<c:when test="${project.projectStatus ne -2}">审批中</c:when>
										<c:otherwise>---</c:otherwise>
									</c:choose>
								</td>
							</tr>
						</c:forEach>
					</c:if>
					
					<c:choose>
						<c:when test="${fn:length(e[0]) gt 0 && fn:length(e[1]) gt 0}">
							<tr ${subIdx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
								<td rowspan="${fn:length(e[1])}"><b>${fn:length(e[1])}</b> (参与)</td>
								<c:forEach items="${partiEntity}" var="project" begin="0" end="0">
									<td style="text-align:center">${project.projectNo}</td>
									<td style="text-align:left">${project.projectName}</td>
									<td><fmt:formatDate value="${project.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
									<td>${project.projectRecorder ne null ? project.projectRecorder.username : '---'}</td>
									<td><fmt:formatDate value="${project.projectCreationTime}" type="date" pattern="yyyy-MM-dd"/></td>
									<td style="text-align:left">${project.projectType.dictKey}</td>
									<td>
										<c:choose>
											<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">项目分配</c:when>
											<c:when test="${project.currentProcess ne null}">${project.currentProcess.nodeTitle}</c:when>
											<c:otherwise>---</c:otherwise>
										</c:choose>
									</td>
									<td ${project.projectStatus eq -2 ? 'style="background-color: #FF9500"' :  (project.projectStatus eq -1 ? 'style="background-color: #FFD20F"' : '')}>
										<c:choose>
											<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">待分配</c:when>
											<c:when test="${project.projectStatus eq 0}">材料待提交</c:when>
											<c:when test="${project.projectStatus eq 1}">审批中</c:when>
											<c:when test="${project.projectStatus eq -1}">审批退回</c:when>
											<c:when test="${project.projectStatus eq -2}">已暂停</c:when>
											<c:when test="${project.projectStatus eq 2 || project.projectStatus eq 3}">审批结束</c:when>
											<c:otherwise>---</c:otherwise>
										</c:choose>
									</td>
									<td class="ps_${project.projectStatus}">
										<c:choose>
											<c:when test="${project.projectStatus eq 2}">否决</c:when>
											<c:when test="${project.projectStatus eq 3}">通过</c:when>
											<c:when test="${project.projectStatus ne -2}">审批中</c:when>
											<c:otherwise>---</c:otherwise>
										</c:choose>
									</td>
								</c:forEach>
							</tr>
						</c:when>
						<c:otherwise>
							
						</c:otherwise>
					</c:choose>
					
					<c:if test="${fn:length(e[1]) gt 1}">
						<c:forEach items="${partiEntity}" var="project" begin="1">
							<tr ${subIdx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
								<td style="text-align:center">${project.projectNo}</td>
								<td style="text-align:left">${project.projectName}</td>
								<td><fmt:formatDate value="${project.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
								<td>${project.projectRecorder ne null ? project.projectRecorder.username : '---'}</td>
								<td><fmt:formatDate value="${project.projectCreationTime}" type="date" pattern="yyyy-MM-dd"/></td>
								<td style="text-align:left">${project.projectType.dictKey}</td>
								<td>
									<c:choose>
										<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">项目分配</c:when>
										<c:when test="${project.currentProcess ne null}">${project.currentProcess.nodeTitle}</c:when>
										<c:otherwise>---</c:otherwise>
									</c:choose>
								</td>
								<td ${project.projectStatus eq -2 ? 'style="background-color: #FF9500"' :  (project.projectStatus eq -1 ? 'style="background-color: #FFD20F"' : '')}>
									<c:choose>
										<c:when test="${project.currentProcess eq null && project.projectStatus eq 1}">待分配</c:when>
										<c:when test="${project.projectStatus eq 0}">材料待提交</c:when>
										<c:when test="${project.projectStatus eq 1}">审批中</c:when>
										<c:when test="${project.projectStatus eq -1}">审批退回</c:when>
										<c:when test="${project.projectStatus eq -2}">已暂停</c:when>
										<c:when test="${project.projectStatus eq 2 || project.projectStatus eq 3}">审批结束</c:when>
										<c:otherwise>---</c:otherwise>
									</c:choose>
								</td>
								<td class="ps_${project.projectStatus}">
									<c:choose>
										<c:when test="${project.projectStatus eq 2}">否决</c:when>
										<c:when test="${project.projectStatus eq 3}">通过</c:when>
										<c:when test="${project.projectStatus ne -2}">审批中</c:when>
										<c:otherwise>---</c:otherwise>
									</c:choose>
								</td>
							</tr>
						</c:forEach>
					</c:if>
					
				</logic:iterate>
			</logic:present>
		</tbody>
	</table>
</div>